package org.dding.msc.service;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ServiceStateManager {

	private ConcurrentHashMap<ServiceName, ServiceState> dependencies = new ConcurrentHashMap<ServiceName, ServiceState>();

	public static ServiceStateManager getInstance() {
		return ResourceHolder.managerHolder;
	}

	private static class ResourceHolder {
		public static ServiceStateManager managerHolder = new ServiceStateManager();
	}

	public ServiceState getServiceState(ServiceName serviceName) {
		return dependencies.get(serviceName);
	}
	
	public void setServiceState(ServiceName serviceName,ServiceState state) {
		dependencies.put(serviceName,state);
	}

	public Map<ServiceName, ServiceState> getServiceStates() {
		return Collections.unmodifiableMap(dependencies);
	}

}
